import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;

import java.io.IOException;

@WebServlet("/e")
public class ServletE extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        session.setAttribute("s1","aaaaa");
        String targetUrl = request.getContextPath()+"/f";
        String encodedUrl = response.encodeRedirectURL(targetUrl);
        System.out.println(session.getId());
        response.sendRedirect(encodedUrl);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}